package rad.framework.mda.generator.template.main.java.jmx;

import java.util.*;
import rad.framework.mda.generator.util.*;
import org.eclipse.emf.codegen.util.*;

public class Component
{
  protected static String nl;
  public static synchronized Component create(String lineSeparator)
  {
    nl = lineSeparator;
    Component result = new Component();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "";
  protected final String TEXT_2 = "/*" + NL + " * ============================================================================" + NL + " *                   GNU Lesser General Public License" + NL + " * ============================================================================" + NL + " */" + NL + "package ";
  protected final String TEXT_3 = ";";
  protected final String TEXT_4 = NL;
  protected final String TEXT_5 = NL + NL + "/**" + NL + " * ";
  protected final String TEXT_6 = NL + " *" + NL + " * @author ";
  protected final String TEXT_7 = NL + " * @generated" + NL + " */";
  protected final String TEXT_8 = NL;
  protected final String TEXT_9 = NL + "public class ";
  protected final String TEXT_10 = "Bean implements ";
  protected final String TEXT_11 = " {" + NL + "" + NL + "\t/** @generated */" + NL + "\t@Logger" + NL + "\tprivate Log log;";
  protected final String TEXT_12 = NL + NL + "\t/** @generated */" + NL + "\t";
  protected final String TEXT_13 = "@In(\"";
  protected final String TEXT_14 = "\")";
  protected final String TEXT_15 = NL + "\tprotected ";
  protected final String TEXT_16 = " ";
  protected final String TEXT_17 = ";\t";
  protected final String TEXT_18 = NL + NL + "\t/**" + NL + "\t * ";
  protected final String TEXT_19 = NL + "\t * @generated" + NL + "\t */" + NL + "\t";
  protected final String TEXT_20 = NL + "\tpublic ";
  protected final String TEXT_21 = " ";
  protected final String TEXT_22 = "(";
  protected final String TEXT_23 = ") {" + NL + "\t}";
  protected final String TEXT_24 = NL + NL + "\t/** @generated */" + NL + "\t@Create" + NL + "\tpublic void create() throws Exception {" + NL + "\t}" + NL + "    " + NL + "\t/** @generated */" + NL + "\t@Destroy" + NL + "\tpublic void destroy() throws Exception {" + NL + "\t}" + NL + "" + NL + "\t/** @generated */" + NL + "\tpublic static ";
  protected final String TEXT_25 = " instance() {" + NL + "\t\treturn (";
  protected final String TEXT_26 = ") Component.getInstance(";
  protected final String TEXT_27 = "Bean.class);" + NL + "\t}" + NL + "}";
  protected final String TEXT_28 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    org.eclipse.uml2.uml.Interface uml2Interface = (org.eclipse.uml2.uml.Interface) argument;org.eclipse.uml2.uml.Package uml2Package = uml2Interface.getPackage();
    stringBuffer.append(TEXT_1);
    stringBuffer.append(TEXT_2);
    stringBuffer.append(NameHelper.getQualifiedName(uml2Package));
    stringBuffer.append(TEXT_3);
    ImportManager importManager = ImportHelper.makeImportManager("");
    stringBuffer.append(TEXT_4);
    importManager.addImport("java.util.ArrayList");
    importManager.addImport("java.util.Collection");
    importManager.addImport("java.util.Calendar");
    importManager.addImport("java.util.HashMap");
    importManager.addImport("java.util.Iterator");
    importManager.addImport("java.util.List");
    importManager.addImport("java.util.Map");
    importManager.addImport("org.jboss.seam.Component");
    importManager.addImport("org.jboss.seam.annotations.Logger");
    importManager.addImport("org.jboss.seam.log.Log");
    importManager.addImport("org.jboss.seam.annotations.Create");
    importManager.addImport("org.jboss.seam.annotations.Destroy");
    importManager.addImport("org.jboss.seam.annotations.In");
    
StringBuffer importStringBuffer = stringBuffer;
int importInsertionPoint = stringBuffer.length();
importManager.addCompilationUnitImports(stringBuffer.toString());

    stringBuffer.append(TEXT_5);
    stringBuffer.append(TypeHelper.getDocumentation(uml2Interface));
    stringBuffer.append(TEXT_6);
    stringBuffer.append(System.getProperty("user.name"));
    stringBuffer.append(TEXT_7);
    stringBuffer.append(TEXT_8);
    stringBuffer.append(StereotypeHelper.getAnnotations(uml2Interface, false));
    stringBuffer.append(TEXT_9);
    stringBuffer.append(NameHelper.getCapName(uml2Interface));
    stringBuffer.append(TEXT_10);
    stringBuffer.append(NameHelper.getCapName(uml2Interface));
    stringBuffer.append(TEXT_11);
    for (Iterator i=uml2Interface.getClientDependencies().iterator(); i.hasNext();) { org.eclipse.uml2.uml.Dependency dependency = (org.eclipse.uml2.uml.Dependency)i.next();
    stringBuffer.append(TEXT_12);
    if (StereotypeHelper.isStereotypeApplied(dependency, "org.jboss.seam.annotations.In")) {
    stringBuffer.append(StereotypeHelper.getAnnotations(dependency));
    } else {
    stringBuffer.append(TEXT_13);
    stringBuffer.append(StereotypeHelper.getValue(InterfaceHelper.getDependency(dependency), "org.jboss.seam.annotations.In", "value"));
    stringBuffer.append(TEXT_14);
    }
    stringBuffer.append(TEXT_15);
    stringBuffer.append(InterfaceHelper.getDependencyType(dependency));
    stringBuffer.append(TEXT_16);
    stringBuffer.append(InterfaceHelper.getDependencyName(dependency));
    stringBuffer.append(TEXT_17);
    }
    for (Iterator i=uml2Interface.getOwnedOperations().iterator(); i.hasNext();) { org.eclipse.uml2.uml.Operation operation = (org.eclipse.uml2.uml.Operation)i.next();
    stringBuffer.append(TEXT_18);
    stringBuffer.append(TypeHelper.getDocumentation(operation));
    stringBuffer.append(TEXT_19);
    stringBuffer.append(StereotypeHelper.getAnnotations(operation));
    stringBuffer.append(TEXT_20);
    stringBuffer.append(InterfaceHelper.getReturn(operation));
    stringBuffer.append(TEXT_21);
    stringBuffer.append(operation.getName());
    stringBuffer.append(TEXT_22);
    stringBuffer.append(InterfaceHelper.getParameters(operation));
    stringBuffer.append(TEXT_23);
    }
    stringBuffer.append(TEXT_24);
    stringBuffer.append(NameHelper.getCapName(uml2Interface));
    stringBuffer.append(TEXT_25);
    stringBuffer.append(NameHelper.getCapName(uml2Interface));
    stringBuffer.append(TEXT_26);
    stringBuffer.append(NameHelper.getCapName(uml2Interface));
    stringBuffer.append(TEXT_27);
    importStringBuffer.insert(importInsertionPoint, importManager.computeSortedImports());
    stringBuffer.append(TEXT_28);
    return stringBuffer.toString();
  }
}
